var main = {
    search : urlParse() ,
    init : function () {
        // url上带着openId和shopOpenId说明是第一次访问首页
        if (this.search.openId && this.search.shopOpenId) {
            ajax.get({
                url : '/snapshot/home/initUser.do' ,
                data : {
                    openId : this.search.openId ,
                    shopOpenId : this.search.shopOpenId
                } ,
                success : function (resp) {
                    if (resp.success) {
                        window.localStorage.setItem('shop' , JSON.stringify(resp.value.shop));
                        window.localStorage.setItem('user' , JSON.stringify(resp.value.user));
                        document.title = resp.value.shop.name + '欢迎您,' + resp.value.user.nickName;
                    }
                } ,
                error : function (resp) {
                }
            });
        }
    }
}
window.addEventListener("DOMContentLoaded" , function () {
    main.init();
} , false);